package logger

import (
	"os"

	"go.uber.org/zap"
)

func NewLogger() (*zap.Logger, error) {
	zapCfg := zap.NewProductionConfig()

	switch os.Getenv("LOG_LEVEL") {
	case "DEBUG":
		zapCfg.Level.SetLevel(zap.DebugLevel)
	case "WARNING":
		zapCfg.Level.SetLevel(zap.WarnLevel)
	case "ERROR":
		zapCfg.Level.SetLevel(zap.ErrorLevel)
	default:
		zapCfg.Level.SetLevel(zap.InfoLevel)
	}

	return zapCfg.Build()
}
